<template>
    <div>
        <table>
            <thead>
            <tr>
                <td></td>
            </tr>
            </thead>
        </table>
        <div class="file-list">
            <table>
                <tbody>
                <tr v-for="(file,key) in fileList" :key="key" @click="showLocalFolder(file)">
                    <td v-text="file.name"></td>
                    <td v-text="checkLoadType(file.loadType)"></td>
                    <td v-text="publicFun.getFileSize(file.size)"></td>
                    <td v-text="publicFun.rebuildTime(file.overTime,1)"></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

</template>

<script>
  export default {
    name: "overList",
    data() {
      return {
        fileList: []
      }
    },
    created() {
      const that = this;
      this.fileList = this.$ipcRenderer.sendSync('getLoadOverList')
      this.$ipcRenderer.on('loadOverAlert', function () {
        that.fileList = that.$ipcRenderer.sendSync('getLoadOverList')
      })
      console.log(this.fileList)
    }, methods: {
      showLocalFolder: function (fileData) {
        console.log(fileData)
        // this.testDwonload(fileData)
        this.$shell.showItemInFolder(fileData.path)
      },
      testDwonload:function(fileData){
        const that = this
        this.$http.post('/pan/file/download/v1', {fileId: [fileData.fileId]}).then(function (data) {
          console.log(data)
          if (data.data.code === 1) {
            that.$ipcRenderer.send('downloadFile', data.data.data)
          }
        })

      },
      checkLoadType:function (loadType) {
        if(loadType === 'download'){
          return '下载成功'
        }else  if(loadType === 'upload'){
          return '上传成功'
        }else  if(loadType === 'fastUpload'){
          return '极速秒传'
        }
      }
    }
  }
</script>

<style scoped>
    .file-list {
        width: 100%;
    }

    .file-list table {
        width: 100%;
    }

    .file-list table td {
        text-align: center;
        line-height: 30px;
    }

</style>
